<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setCharacterEncoding("utf-8");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String sex = request.getParameter("sex");
		String addr = request.getParameter("addr");
		String intro = request.getParameter("intro");
		
		out.println("username --> " + username);
		out.println("<br/>");
		out.println("password --> " + password);
		out.println("<br/>");
		out.println("sex --> " + sex);
		out.println("<br/>");
		out.println("addr --> " + addr);
		out.println("<br/>");
		out.println("intro --> " + intro);
		out.println("<br/>");
		
		Class.forName("com.mysql.jdbc.Driver");
		String url = "jdbc:mysql://localhost:3306/test";
		Connection conn = DriverManager.getConnection(url, "root", "");
		Statement stmt = conn.createStatement();
		String sql = "insert into user (username, password, sex, addr, intro) values ('"+ username +"', '"+ password +"', "+ sex +", '"+ addr +"', '"+ intro +"')";
		out.println(sql);
		out.println("<br/>");
		stmt.executeUpdate(sql);
		stmt.close();
		conn.close();
	%>
</body>
</html>
